from time import sleep
from selenium.webdriver.common.by import By
from testing.testHomework2.poHomeWork.Page.addDepartmentPage import AddDepartmentPage
from testing.testHomework2.poHomeWork.Page.basePage import BasePage


class ContactPage(BasePage):
    # 加号元素
    _add = (By.CSS_SELECTOR, '.member_colLeft_top_addBtn:nth-child(1)')
    #添加部门元素
    _addDepartment=(By.CSS_SELECTOR, '.js_create_party')
    #部门定位元素
    _department = (By.XPATH, '//li[@role="treeitem"]/a')
    #点击添加部门
    def getDepartmentPage(self):
        self.wait_for_click(self._add)
        sleep(2)
        self.find_and_click(*self._addDepartment)
        return AddDepartmentPage(self.driver)
    #获取部门
    def getDepartments(self):
        self.driver.implicitly_wait(3)
        datas = self.finds(*self._department)
        list = []
        for x in datas:
            list.append(x.text)
        return list